#pragma once
#include<iostream>
using namespace std;

class Date
{

	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in, Date& d);
public:
	Date(int year = 1, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}
	~Date()
	{

	}
	Date(const Date& d)
	{
		_year = d._year;
		_month = d._month;
		_day = d._day;
	}
	Date& operator=(const Date& d)
	{
		_year = d._year;
		_month = d._month;
		_day = d._day;
		return *this;
	}

	bool CheckDate()
	{
		if ((_year > 0 && (_month > 0 && _month <= 12)) &&(_day > 0 && _day <= GetMonthDay()))
			return true;
		return false;
	}
	void Printf()
	{
		cout << _year << " " << _month << " " << _day << " " << endl;
	}
	int GetMonthDay()
	{
		static int monthArr[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
		if (_month == 2 && (_year % 4 == 0 && _year % 100 != 0) || _year % 400 == 0)
		{
			return 29;
		}
		return monthArr[_month];
	}
	bool operator==(const Date& d)const;
	bool operator!=(const Date& d)const;
	bool operator>=(const Date& d)const;
	bool operator<=(const Date& d) const;
	bool operator>(const Date& d) const;
	bool operator<(const Date& d) const;
	Date operator+(int day);
	Date& operator+=(int d);
	Date operator-(int day);
	Date& operator-=(int d);
	Date& operator++();
	Date operator++(int);
	int operator-(const Date& d);


private:
	int _year;
	int _month;
	int _day;
};

ostream& operator<<(const ostream& out, const Date& d);
istream& operator>>(const istream& in,  Date& d);

